<?php

namespace App\Http\Controllers;

use App\models\forum\Moderator;
use App\models\user\User;
use Auth;
use Illuminate\Http\Request;
use Log;
use Validator;

class ErrorController extends Controller
{
    public function pass(){
        return view('errors.norole');
    }

    public function test(Request $request){
        $validator = Validator::make($request->all(), [
            'api_token'     => 'required|min:256|max:256'
        ]);

        if ($validator->fails()){
            return ['success' => false, 'result' => '参数不正确'];
        }
        return ['success' => true,
            'result' => [
                "count" => '0',
                'items' => [
                    [
                        "id"            => 1,
                        "volume"        => '2G',
                        'mobile'        => "18916455881",
                        'card_coed'     => "asdsadasdsa3qedsad",
                        'card_pass'     => 'dasdsadaseerfsdasa'
                    ],
                    [
                        'id'            => 2,
                        "volume"        => '2G',
                        'mobile'        => "18916455882",
                        'card_coed'     => "sdasdsacxzfefzxczx",
                        'card_pass'     => 'sdasdascwrgdxvqed'
                    ], 
                    [
                        'id'            => 3,
                        "volume"        => '2G',
                        'mobile'        => "18916455883",
                        'card_coed'     => "adsadsadsadsadasd",
                        'card_pass'     => 'sadsafdsczdfascxzs'
                    ],
                ]
            ]
        ];
    }

    public function test2(Request $request){
        $arr=array('name' => Auth::user()->name,  'session_id' => encrypt($request->getSession()->getId()));
        $result=json_encode($arr);
        $callback=$request->get('jsoncallback');
        return $callback."($result)";
    }
}
